﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="CurrencyRate.aspx.cs" Inherits="Master_CurrencyRate" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="bodyContentTop" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="bodyContent" Runat="Server">
        <div class="elements_inner_wrapper">
        <div id="contentBody">
            <div class="section">
                <div class="seperator">
                </div>
                <fieldset class="formouter">
                    <table cellpadding="3" cellspacing="3" width="100%">
                        <tr>
                            <td valign="top">
                                <h2> Currency Rate Details </h2>
                                <div class="row_curved" id="divLocationCode" runat="server">
                                    <label for="<%=ddlFromCurrency.ClientID%>" class="mand_red">
                                        <asp:Label runat="server" Text="From Currency" ID="lblLocationCode" /></label>
                                    <div class="field">
                                        <span class="indicator">
                                            <asp:DropDownList ID="ddlFromCurrency" runat="server"></asp:DropDownList>                                             
                                             <asp:CustomValidator ID="cvFromCurrency" runat="server" ControlToValidate="ddlFromCurrency" 
                                             ValidationGroup="CurrencyRate" CssClass="validationErrorControl" Display="None"
                                             OnServerValidate="FromCurrencyServerValidate" ErrorMessage="From Currency may not valid."></asp:CustomValidator>
                                             <asp:RequiredFieldValidator ID="rfvFromCurrency" runat="server" ControlToValidate="ddlFromCurrency" ErrorMessage="Please select" Display="Dynamic"></asp:RequiredFieldValidator>
                                        </span>
                                    </div>
                                    <div class="clear">
                                    </div>
                                </div>
                                <div class="row_curved" id="divDescription" runat="server">
                                    <label for="<%=ddlToCurrency.ClientID%>" class="mand_red">
                                        <asp:Label runat="server" Text="To Currency" ID="lblLocationName" /></label>
                                    <div class="field">
                                        <span class="indicator">
                                             <asp:DropDownList ID="ddlToCurrency" runat="server"></asp:DropDownList>
                                              <asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="ddlToCurrency" 
                                             ValidationGroup="CurrencyRate" CssClass="validationErrorControl" Display="None"
                                             OnServerValidate="FromCurrencyServerValidate" ErrorMessage="To Currency may not valid."></asp:CustomValidator>
                                             <asp:RequiredFieldValidator ID="rfvToCurrency"  runat="server" ControlToValidate="ddlToCurrency" ErrorMessage="require" Display="Dynamic"></asp:RequiredFieldValidator>
                                            
                                        </span>
                                    </div>
                                    <div class="clear">
                                    </div>
                                </div>
                                <div class="row_curved" id="div1" runat="server">
                                    <label for="<%=txtCurrencyRate.ClientID%>" class="mand_red">
                                        <asp:Label runat="server" Text="Rate" ID="lblRate" /></label>
                                    <div class="field">
                                        <span class="indicator">
                                            <asp:TextBox Width="270px" ID="txtCurrencyRate"  MaxLength="10" runat="server" />    
                                            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" ValidationGroup="CurrencyRate"
                                                ControlToValidate="txtCurrencyRate" runat="server" CssClass="validationErrorControl"
                                                Display="Dynamic" ErrorMessage="<br />Invalid Input Data." ValidationExpression="^[1-9]\d*(\.\d+)?$"></asp:RegularExpressionValidator>                                         
                                        </span>
                                    </div>
                                    <div class="clear">
                                    </div>
                                </div>                                 
                                 
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <div class="row_curved" style="background-color: #efefef;" id="divButton" runat="server">                                     
                                    <div class="field">
                                        <span class="indicator">
                                            <asp:Button ID="btnSubmit" CssClass="button_normal_submit" Text="Save" ValidationGroup="CurrencyRate"
                                                OnClientClick="SubmitOnClientClick(this, 'CurrencyRate');" runat="server" OnClick="btnSubmit_Click" /></span>
                                        &nbsp;&nbsp;<asp:Button runat="server" ID="btnAdd" Text="New" 
                                            OnClick="btnAdd_Click"  CssClass="button_normal_submit" Width="52px" />                                         
                                         
                                    </div>
                                    <div class="clear">
                                    </div>
                                </div>
                                <div class="row_curved" id="divMessage" runat="server">
                                    <label>
                                        &nbsp;</label>
                                    <div class="field">
                                        <span class="indicator">
                                            <asp:Label ID="lblMessage" Font-Bold="true" runat="server"></asp:Label>
                                        </span>
                                    </div>
                                    <div class="clear">
                                    </div>
                                </div>
                            </td>
                        </tr>
                        <tr>
                                <td colspan="2">
                                    <h2>Currency Rate Listing</h2>
                                    <asp:GridView ID="grvCurrencyRate" runat="server" AutoGenerateColumns="False" DataKeyNames="CurrencyRateKey"
                                        CellPadding="4" Width="550px" DataSourceID="odsCurrencyRate" ForeColor="#333333" 
                                        GridLines="None" OnSelectedIndexChanged="grvCurrencyRate_SelectedIndexChanged" OnRowDeleting="grvCurrencyRate_RowDeleting">
                                        <RowStyle BackColor="#EFF3FB" />
                                        <Columns>
                                            <asp:BoundField DataField="CurrencyRateKey" HeaderText="CurrencyRateKey" InsertVisible="False" Visible="false"
                                                ReadOnly="True" SortExpression="CurrencyRateKey"/>
                                            <asp:BoundField DataField="FromCurrency" HeaderText="FromCurrency" SortExpression="FromCurrency" />
                                            <asp:BoundField DataField="ToCurrency" HeaderText="ToCurrency" SortExpression="ToCurrency" />
                                            <asp:BoundField DataField="Rate" HeaderText="Rate" SortExpression="Rate" DataFormatString="{0:N2}"/>                                         
                                            <asp:CheckBoxField DataField="Status" HeaderText="Status" Visible="false"
                                                SortExpression="Status" />
                                            <asp:BoundField DataField="CreatedDateTime" HeaderText="CreatedDateTime" DataFormatString="{0:dd/MM/yyyy}"
                                                SortExpression="CreatedDateTime" />                                            
                                            <asp:BoundField DataField="ModifiedDateTime" HeaderText="ModifiedDateTime" DataFormatString="{0:dd/MM/yyyy}"
                                                SortExpression="ModifiedDateTime" />
                                            <asp:TemplateField>
                                                <ItemTemplate>
                                                    <asp:LinkButton ID="lnkbtnEdit" runat="server" CausesValidation="False" CommandName="Select" Text="Edit"></asp:LinkButton> 
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:CommandField ShowDeleteButton="true" ButtonType="Link" />
                                    </Columns>
                                    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                                    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                                    <EmptyDataTemplate>
                                        Please Add New Currency Rate.
                                    </EmptyDataTemplate>
                                    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                                    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                                    <EditRowStyle BackColor="#2461BF" />
                                    <AlternatingRowStyle BackColor="White" />
                                </asp:GridView>
                                    <asp:ObjectDataSource ID="odsCurrencyRate" runat="server" 
                                        OldValuesParameterFormatString="original_{0}" SelectMethod="GetList" TypeName="CurrencyRateTableManager" DeleteMethod="Delete" 
                                        DataObjectTypeName="CurrencyRateTable">
                                    </asp:ObjectDataSource>
                                     
                                </td>
                            </tr>
                        <tr>
                            <td colspan="2" valign="top">
                                <div>
                                    <asp:ValidationSummary ID="vsCurrencyRate" runat="server" ValidationGroup="CurrencyRate"
                                        ShowSummary="True" HeaderText="Please complete all highlighted fields of the form. Thank you."
                                        CssClass="errorSummary" />  
                                        <asp:Label Visible="false" runat="server" Text="-1" ID="lblCurrencyRateKey" />                                   
                                </div>
                            </td>
                        </tr>
                        
                    </table>
                </fieldset>
            </div>
            </div>
            </div>
        <script type="text/javascript">
        //<![CDATA[
            SetSumitNormalButtonAttribute(document.getElementById('<%=btnSubmit.ClientID%>'));
        //]]>        
        
        function CountryCheck(source, args)
        {
            var ddlCountry = document.getElementById("<%=ddlToCurrency.ClientID%>");
            var country = ddlToCurrency.options[ddlToCurrency.selectedIndex].value;
            if (country == "0")
            {
                args.IsValid = false;
            }
            else
            {
                args.IsValid = true;
            }
      
        } 
 
    </script>
</asp:Content>

